From d84d19e5ee1a42a90ffc3b6e6aedc2314fb209f6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=98yvind=20Kol=C3=A5s?= Date: Wed, 11 Apr 2012 00:05:28 +0200 Subject: [PATCH] tests: added test to extract a component --- tests/Makefile.am | 1 + tests/extract.c | 96 +++++++---------------------------------------- 2 files changed, 14 insertions(+), 83 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index ba88a9c..469a819 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -9,6 +9,7 @@ TESTS = \ srgb_to_lab_u8 \ sanity \ babl_class_name \ + extract \ types \ palette \ extract \ diff --git a/tests/extract.c b/tests/extract.c index 6f6e927..038c667 100644 --- a/tests/extract.c +++ b/tests/extract.c @@ -41,104 +41,34 @@ for (c = 0; c < sizeof(expected_pix[i])/sizeof(expected_pix[i][0]); c++) \ if (result[c] != expected_pix[i][c]) \ { \ - printf (" %s failed #%i[%i] %i\n", test_name, i, c, result[c]); \ + printf (" %s failed #%i[%i] got %i expected %i\n", test_name, i, c, result[c], expected_pix[i][c]); \ OK = 0; \ } \ } \ } +#include + int main (int argc, char **argv) { int OK = 1; babl_init (); - { - char in[][4] = {{0,1,2,3},{4,5,6,7},{8,9,10,11}}; - char out[][1] = {{ 3},{ 7},{ 11}}; - - babl_format_new ("name", "A u8", - babl_model ("YA"), babl_type ("u8"), - babl_component ("A"), NULL); - - CHECK_CONV("extract alpha", char, - babl_format("RGBA u8"), babl_format("A u8"), + unsigned char in[][4] = {{0,1,2,3 },{4,5,6,7 },{8,9,10,11 }}; + unsigned char out[][1] = { {2 }, {6} , {10} }; + + CHECK_CONV("extract B'", unsigned char, + babl_format("R'G'B'A u8"), + babl_format_new ("name", "B' u8", + babl_model ("R'G'B'A"), + babl_type ("u8"), + babl_component ("B'"), + NULL), in, out); } - { - char in[][4] = {{0,1,2,3},{4,5,6,7},{8,9,10,11}}; - char out[][1] = {{ 1 },{ 5 },{ 9 }}; - - babl_format_new ("name", "G u8", - babl_model ("RGBA"), babl_type ("u8"), - babl_component ("G"), NULL); - - CHECK_CONV("extract green", char, - babl_format("RGBA u8"), babl_format("G u8"), - in, out); - } - - - { - char in[][4] = {{0,1,2,3},{4,5,6,7},{8,9,10,11}}; - char out[][2] = {{ 2,1 },{ 6,5 },{ 10,9 }}; - - babl_format_new ("name", "BG u8", - babl_model ("RGBA"), babl_type ("u8"), - babl_component ("B"), - babl_component ("G"), NULL); - - CHECK_CONV("extract green", char, - babl_format("RGBA u8"), babl_format("BG u8"), - in, out); - } - - - - { - float in[][4] = {{0,1,2,3/255.0},{4,5,6,277/255.0},{8,9,10,101/255.0}}; - char out[][1] = {{ 3}, { 255},{ 101}}; - - CHECK_CONV("extract alpha from float", char, - babl_format("RGBA float"), babl_format("A u8"), - in, out); - } - - { - char in[][4] = {{1,2,3,4},{4,5,6,7},{8,9,10,11}}; - char out[][4] = {{4,3,2,1},{7,6,5,4},{11,10,9,8}}; - - babl_format_new ("name", "abgr", - babl_model ("RGBA"), babl_type ("u8"), - babl_component ("A"), - babl_component ("B"), - babl_component ("G"), - babl_component ("R"), - NULL); - - CHECK_CONV("bgra", char, - babl_format("RGBA u8"), babl_format("abgr"), - in, out); - } - - { - char in[][4] = {{1,2,3,4},{4,5,6,7},{8,9,10,11}}; - //char out[][4]= {{3,0,0,4},{6,0,0,7},{10,0,0,11}}; - char out[][4] = {{3,3,3,4},{6,6,6,7},{10,10,10,11}}; - - CHECK_CONV("bPADa", char, - babl_format("RGBA u8"), - babl_format_new (babl_model ("RGBA"), babl_type ("u8"), - babl_component ("B"), - babl_component ("PAD"), - babl_component ("PAD"), - babl_component ("A"), - NULL), - in, out); - } - babl_exit (); return !OK; } -- 2.30.2